-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix serialization order change after #4775 (@JsonAnyGetter
respects order)
#5216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
private Map<String, POJOPropertyBuilder> _putAnyGettersInTheEnd(Map<String, POJOPropertyBuilder> all, Map<String, POJOPropertyBuilder> props) { | ||
for (POJOPropertyBuilder prop : props.values()) { | ||
all.put(prop.getName(), prop); | ||
} | ||
Map<String, POJOPropertyBuilder> newAll = new LinkedHashMap<String,POJOPropertyBuilder>(props.size()+props.size()); | ||
POJOPropertyBuilder anyGetterProp = null; | ||
for (POJOPropertyBuilder prop : all.values()) { | ||
if (prop.getAccessor() != null && Boolean.TRUE.equals(this._config.getAnnotationIntrospector().hasAnyGetter(prop.getAccessor()))) { | ||
anyGetterProp = prop; | ||
} else { | ||
newAll.put(prop.getName(), prop); | ||
} | ||
} | ||
if (anyGetterProp != null) { | ||
newAll.put(anyGetterProp.getName(), anyGetterProp); | ||
} | ||
return newAll; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This puts anyGetter prop in the end by default, before we go sorting downstream in _sortProperties
@@ -502,7 +502,7 @@ public void testDuplicateGetters() throws Exception | |||
assertTrue(prop.getGetter().hasAnnotation(B.class)); | |||
} | |||
|
|||
@Test | |||
// @Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to figure this out first.
Map<String, POJOPropertyBuilder> newAll = new LinkedHashMap<String,POJOPropertyBuilder>(props.size()+props.size()); | ||
POJOPropertyBuilder anyGetterProp = null; | ||
for (POJOPropertyBuilder prop : all.values()) { | ||
if (prop.getAccessor() != null && Boolean.TRUE.equals(this._config.getAnnotationIntrospector().hasAnyGetter(prop.getAccessor()))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we really should not do annotation introspector here, again...
Oh wow, thank you for the extra work @cowtowncoder 👍👍 almost seems like a brand new PR |
Np. I got bit carried away. But the logic remains the way it was so it's still your PR :) Will now merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #5215 (caused by #4775)